package com.lzb.basic.picselect;

import android.os.Build;

import androidx.annotation.Keep;

import java.io.Serializable;

@Keep
public class SelectMediaEntity implements Serializable {

    /**
     * android 10的路径
     */
    private String androidQPath;
    /**
     * 此值在android 10以上有可能无法访问，取决于存储模式，媒体的真实路径 也就是绝对路径
     */
    private String realPath;
    /**
     * 文件的路径
     */
    private String path;

    private String mimeType;

    private MediaType.Type type;

    private long duration;

    private String mediaName;

    private long size;

    private int width;

    private int height;

    /**
     * 该素材的加入媒体库的时间即创建时间
     * 单位：秒
     */
    private int dateAdded;

    private boolean isChecked;
    /**
     * bucketId 相册对应的id
     */
    private long bucketId = -1;

    private String uri;


    public SelectMediaEntity(String uri, String realPath, String path, String mimeType,
                             long duration, String mediaName, long size, int width, int height,
                             int dateAdded) {
        this.realPath = realPath;
        this.uri = uri;
        this.path = path;
        this.mimeType = mimeType;
        this.duration = duration;
        this.mediaName = mediaName;
        this.size = size;
        this.width = width;
        this.height = height;
        this.dateAdded = dateAdded;
    }

    public SelectMediaEntity() {
    }

    public String getUri() {
        return uri;
    }

    public void setUri(String uri) {
        this.uri = uri;
    }

    public String getAndroidQPath() {
        return androidQPath;
    }

    public void setAndroidQPath(String androidQPath) {
        this.androidQPath = androidQPath;
    }

    public String getRealPath() {
        return realPath;
    }

    public void setRealPath(String realPath) {
        this.realPath = realPath;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public String getMimeType() {
        return mimeType;
    }

    public void setMimeType(String mimeType) {
        this.mimeType = mimeType;
    }

    public MediaType.Type getType() {
        return type;
    }

    public void setType(MediaType.Type type) {
        this.type = type;
    }

    public long getDuration() {
        return duration;
    }

    public void setDuration(long duration) {
        this.duration = duration;
    }

    public String getMediaName() {
        return mediaName;
    }

    public void setMediaName(String mediaName) {
        this.mediaName = mediaName;
    }

    public long getSize() {
        return size;
    }

    public void setSize(long size) {
        this.size = size;
    }

    public int getWidth() {
        return width;
    }

    public void setWidth(int width) {
        this.width = width;
    }

    public int getHeight() {
        return height;
    }

    public void setHeight(int height) {
        this.height = height;
    }

    public boolean isChecked() {
        return isChecked;
    }

    public void setChecked(boolean checked) {
        isChecked = checked;
    }

    public long getBucketId() {
        return bucketId;
    }

    public void setBucketId(long bucketId) {
        this.bucketId = bucketId;
    }

    public int getDateAdded() {
        return dateAdded;
    }

    public void setDateAdded(int dateAdded) {
        this.dateAdded = dateAdded;
    }

    public SelectMediaEntity cloneThis() {
        SelectMediaEntity selectMediaEntity = new SelectMediaEntity();
        selectMediaEntity.setChecked(false);
        selectMediaEntity.setType(type);
        selectMediaEntity.setAndroidQPath(androidQPath);
        selectMediaEntity.setBucketId(bucketId);
        selectMediaEntity.setDuration(duration);
        selectMediaEntity.setHeight(height);
        selectMediaEntity.setMediaName(mediaName);
        selectMediaEntity.setMimeType(mimeType);
        selectMediaEntity.setPath(path);
        selectMediaEntity.setRealPath(realPath);
        selectMediaEntity.setSize(size);
        selectMediaEntity.setUri(uri);
        selectMediaEntity.setWidth(width);
        selectMediaEntity.setDateAdded(dateAdded);
        return selectMediaEntity;
    }


    public String getTargetPath() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
            return androidQPath;
        } else {
            return path;
        }
    }
}
